package 红与黑;

import java.util.*;

public class Main {
    static int N = 30, n, m;
    static char[][] g = new char[N][N];
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-1, 1, 0, 0};
    static int[] dy = {0, 0, -1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (true) {
            m = in.nextInt();
            n = in.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            for (int i = 0; i < n; i++) {
                g[i] = in.next().toCharArray();
            }
            for (int i = 0; i < n; i++) {
                Arrays.fill(st[i], false);
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (g[i][j] == '@') {
                        cnt = dfs(i, j);
                        break;
                    }
                }
            }
            System.out.println(cnt);
        }
    }

    private static int dfs(int x, int y) {
        int cnt = 1;
        st[x][y] = true;
        for (int i = 0; i < 4; i++) {
            int a = dx[i] + x, b = dy[i] + y;
            if (a < 0 || a >= n || b < 0 || b >= m) {
                continue;
            }
            if (st[a][b]) {
                continue;
            }
            if (g[a][b] == '#') {
                continue;
            }
            cnt += dfs(a, b);
        }
        return cnt;
    }
}
